﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<SDT.Mobile.Models.ProductSearchModels>" %>
<%@ Import Namespace = "SDT.Lib.Paging" %>
<%@ Import Namespace = "SDT.Lib.Helpers" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    <%
        var firstName = Model.Category != null ? Model.Category.Name : (Model.ProductType != null ? Model.ProductType.Name : "Bất động sản bán");
        var clientName = Model.City != null ? firstName + " tại " + Model.City.Name : firstName;
        clientName = Model.District != null ? firstName + " tại " + Model.District.Name + " " + Model.City.Name : clientName;
        clientName = Model.ConvertArea != null ? clientName + " diện tích: " + Model.ConvertArea.Name : clientName;
        clientName = Model.ConvertPrice != null ? clientName + " giá: " + Model.ConvertPrice.Name : clientName;
        Response.Write(clientName);
         %>
</asp:Content>
<asp:Content ID="Content6" ContentPlaceHolderID="MetaContent" runat="server">
    <%
        var firstName = Model.Category != null ? Model.Category.Name : (Model.ProductType != null ? Model.ProductType.Name : "Bất động sản bán");
        var clientName = Model.City != null ? firstName + " tại " + Model.City.Name : firstName;
        clientName = Model.District != null ? firstName + " tại " + Model.District.Name + " " + Model.City.Name : clientName;
        clientName = Model.ConvertArea != null ? clientName + " diện tích: " + Model.ConvertArea.Name : clientName;
        clientName = Model.ConvertPrice != null ? clientName + " giá: " + Model.ConvertPrice.Name : clientName;
        var title = string.Empty;
        if (Model.ProductType != null)
        {
            foreach (var item in Model.ProductType.ProductCategories) {
                title +=item.Name+ " | ";
            }
        }
         %>
    <meta name="page-topic" content="<%=clientName %>" />
    <meta name="title" content="<%=title %>" />
    <meta name="keywords" content="Nhà đất, mua bán, cho thuê bất động sản." />
    <meta name="description" content="<%=title %>" />
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="SearchContent" runat="server">
  <% Html.RenderAction("TopSearch", "Product", new { typeid = Model.TypeID, keyword = Model.Keyword }); %>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<div class="tit_bg">
    <span class="tit_name">
        <%var rewrite = Model.ProductType.Name;
          var path = "/" + Html.ToUrlFriendly(rewrite) + string.Format("/p/{0}", Model.TypeID);
        %>          
        <a href="<%=path %>" ><%= Model.ProductType.Name%></a>
    </span>
</div>
    <%if (Model.Products.TotalItemCount == 0)
      { %>
    <div class="tit_new">
        Không tìm thấy kết quả nào</div>
    <%}
      else
      { %>
    <%var lFull = Model.Products.Count > 6 ? Model.Products.Skip(0).Take(6).ToList() : Model.Products.ToList();
      var lSort = Model.Products.Count > 6 ? Model.Products.Skip(6).Take(8).ToList() : null;
      var lNext = Model.Products.Count > 14 ? Model.Products.Skip(14).ToList() : null;
      if (lFull != null)
          foreach (var item in lFull)
          {
              var pathDetail = item.ProductCategory.Name + " tại " + item.District.Name + " " + item.City.Name;
              var dpath = "/" + Html.ToUrlFriendly(pathDetail) + "/" + Html.ToUrlFriendly(item.Title) + "-p-" + item.ID + ".html";
    %>
    <div class="tit_new">
        <a href="<%=dpath %>" class="l_red">
            <%= item.Title%></a>
    </div>
    <p>
        <%= item.Summary != null ? (item.Summary.Length > 200 ? item.Summary.Substring(0, 200) + "...." : item.Summary) : string.Empty%></p>
    <p>
        &nbsp<%=item.AddDate.Value.ToString("dd/MM/yyyy | HH:mm")  %></p>
    <%} %>
    <%if (lSort != null)
      { %>
    <div class="top_tinrao">
        <div class="tit_not_bg">
            <span style="padding-left: 0px"><strong>Tin khác</strong></span>
        </div>
    </div>
    <div class="new_list">
        <ul>
            <%
                
        foreach (var item in lSort)
        {
            var pathDetail = item.ProductCategory.Name + " tại " + item.District.Name + " " + item.City.Name;
            var dpath = "/" + Html.ToUrlFriendly(pathDetail) + "/" + Html.ToUrlFriendly(item.Title) + "-p-" + item.ID + ".html";
            %>
            <li><a href="<%=dpath %>" class="l_blue">
                <%= item.Title%></a> </li>
            <%} %>
        </ul>
    </div>
    <%} %>
    <%if (lNext != null)
      { %>
    <div class="top_tinrao">
        <div class="tit_not_bg" style="margin-top:3px;">
            <span class="next" id="showNext"><strong>Xem tiếp</strong> </span>
        </div>
    </div>
    <div class="new_list" id="next">
        <ul>
            <%
                
                foreach (var item in lNext)
        {
            var pathDetail = item.ProductCategory.Name + " tại " + item.District.Name + " " + item.City.Name;
            var dpath = "/" + Html.ToUrlFriendly(pathDetail) + "/" + Html.ToUrlFriendly(item.Title) + "-p-" + item.ID + ".html";
            %>
            <li><a href="<%=dpath %>" class="l_blue">
                <%= item.Title%></a> </li>
            <%} %>
        </ul>
    </div>
    <script type="text/javascript">

        $(document).ready(function() {
            $("#next").hide();
            $('#showNext').toggle(function() {
                $("#next").show();
            }, function() {
                $("#next").hide();
            });
        });
        </script>
    <%} %>
<div class="pagebarUTH f_r">
    Trang <%= Model.Products.PageNumber%>/<%= Model.Products.PageCount%>
    <%= Html.PagerRewrite(Model.Products.PageSize, Model.Products.PageNumber, Model.Products.TotalItemCount, new
    {       
        key = Model.Keyword
    })%>
 </div>	
 <% } %>
 <div class="clear"></div>
 <div class="line_dot"></div>
 <div class="m_footer">
     <ul>
         <li>
            <div style="margin-top:10px">
                <a href="/home" class="l_blue" >Trang chủ</a>
            </div>
         </li>
         <li>
               <% Html.RenderAction("GetLink", "Link"); %>
         </li>
     </ul>
 </div>
 <div class="clear"></div>
 <% Html.RenderPartial("~/Views/Product/Search.ascx", Model); %> 
 <div class="clear"></div>
</asp:Content>
